package demo1215.pm;

import java.util.Scanner;

/*
4.String s="hijavahehejavahejava";找出字符串中有几个java?

5.键盘接收一个字符串，输出字符串里的大写字母的个数，
小写英文字母的个数，非英文字母的个数
 */
public class Demo_02 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入一个字符串:");
        String s = scan.next();
        int [] count = new int[3];
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c>='A'&&c<='Z'){
                count[0]++;
            }else if (c>='a'&&c<='z'){
                count[1]++;
            }else {
                count[2]++;
            }
        }
        System.out.println("大写字母出现的次数:"+count[0]);
        System.out.println("小写字母出现的次数:"+count[1]);
        System.out.println("其他字母出现的次数:"+count[2]);

    }

    public static void demo01() {
        String s="hijavahehejavahejava";
        int index = -4;
        int count = 0;
        while ((index = s.indexOf("java",index+4))!=-1){
           count++;
        }
        System.out.println(count);
        System.out.println
                (s.length()-s.replace("java", "   ").length());
    }
}
